{{/* This file contains some common template definitions used in the blocks shortcodes. 
The reasoning behind the long and hard-to-remember template names is that these templates are global. */}}
{{ define "shortcodes-blocks_getimage" }}
{{- with resources.Get (printf "images/site-blocks/%s.jpeg" $.name ) -}}
  {{- $.ctx.Scratch.Set $.target . -}}
{{- else -}}
  {{- $cr := site.GetPage "/_common-resources" -}}
  {{- with $cr -}}
    {{- $legacyImage := $cr.Resources.GetMatch (printf "images/**%s*" $.name ) -}}
    {{- with $legacyImage -}}
      {{- $.ctx.Scratch.Set $.target $legacyImage -}}
    {{- else -}}
      {{- errorf "Image matching %q not found _common-resources" $.name -}}
    {{- end -}}
  {{- else -}}
    {{ errorf "[%s] No resource bundle found. Create an empty headless bundle; create content/%s/_common-resources/index.md with \"headless: true\" in front matter. See https://gohugo.io/content-management/page-bundles/#headless-bundle"  $.ctx.Page.Lang $.ctx.Page.Lang }}
    {{- end -}}
  {{- end -}}
{{- end -}}
